export default class Mapper<T> {
  protected enums: { [key: string]: T }
  public getDefaultConstantObj(defaultKey = 'default'): T | null {
    return this.enums[defaultKey] ?? null
  }
  public valueMap(value: number | string | null | undefined): T | null {
    const defaultConstantObj = this.getDefaultConstantObj()
    if (value == null) return defaultConstantObj ?? null
    const values = Object.keys(this.enums)
    const constantObj = this.enums[values.find((_value) => (value + '').includes(_value)) + '']
    return constantObj ?? defaultConstantObj
  }
}
